#include <bits/stdc++.h>
using namespace std;

inline int read() {
	int x = 0, f = 0; char ch = getchar();
	while (ch < '0' or ch > '9') f |= (ch == '-'), ch = getchar();
	while (ch >= '0' and ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int __stk[128], __top;
inline void write(int x) {
    if(x < 0) putchar('-'), x = -x;
	do { __stk[++__top] = x % 10, x /= 10; } while (x);
	while (__top) putchar(__stk[__top--] + '0');
}

const int mod = 998244353;

void Min(int &x, int y) { y < x and (x = y); }
void Max(int &x, int y) { y > x and (x = y); }

void inc(int &x, int y) { (x += y) >= mod and (x -= mod); }
void mul(int &x, int y) { x = 1ll * x * y % mod; }

int q_pow(int x, int k) { int res = 1; for (; k; k >>= 1, mul(x, x)) if (k & 1) mul(res, x); return res; }

bool stmer;

const int N = 6e6 + 10;

int n, m, k, a, b, c, d;
int f[N];
int fx[4][2] = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } };
int  w[4][2] = { { 0, 1 }, { 1, 0 }, { 0,  1 }, {  1, 0 } };

char s[N];

struct node {
    int a, b, d, x, y;
    bool operator < (const node &p) const { return d == p.d ? (x + y) < (p.x + p.y) : d > p.d; }
};

int id(int x, int y) { return (x - 1) * m + y; }

priority_queue<node> q;

bool edmer;
signed main() {
	freopen("stamp.in", "r", stdin);
	freopen("stamp.out", "w", stdout);
	cerr << "[Memory] " << (&stmer - &edmer) / 1024 / 1024 << " MB\n";
    
    n = read(), m = read(), k = read();
    a = read(), b = read(), c = read(), d = read();

    int cnt = 0;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
        cnt++;
        do { s[cnt] = getchar(); } while (s[cnt] != '.' and s[cnt] != '#');
    }

    for (int i = 1; i <= id(n, m); i++) f[i] = n + m + 10;
    f[id(a, b)] = 0, q.push({ a, b, 0, 0, 0 });

    while (!q.empty()) {
        node l = q.top(); q.pop();
        if (f[id(l.a, l.b)] < l.d) continue;
        for (int i = 0; i < 4; i++) {
            int a = l.a + fx[i][0], b = l.b + fx[i][1];
            if (a < 1 or b < 1 or a > n or b > m) continue;
            int d = l.d, x = l.x - w[i][0], y = l.y - w[i][1];
            if (x < 0 or y < 0) {
                if (s[id(a, b)] == '.') x = y = 0;
                else x = y = k - 1, d++;
            }
            if (d < f[id(a, b)]) q.push({ a, b, d, x, y }), f[id(a, b)] = d;
        }
    }

    // for (int i = 1; i <= n; i++, putchar('\n')) {
    //     for (int j = 1; j <= m; j++) cout << f[id(i, j)] << ' ';
    // }

    write(f[id(c, d)]), putchar('\n');

    cerr << "[Runtime] " << (double) clock() / CLOCKS_PER_SEC << " seconds\n";
	return 0;
} 